<!DOCTYPE html>
<html>
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Js文字闪动效果</title>
</head>
<body>
<div id="container">
  
</div>
</body>
<script type="text/javascript">

    function getTextSize(i,incMethod,textLength){
       if(incMethod == 1){
         return (32*Math.abs(Math.sin(i/(textLength/3.14))) );
       }
       if(incMethod == 2){
         return (255*Math.abs(Math.cos(i/(textLength/3.14))));
       } 
    }
     
    function changeTextSize(text,method,dis){
      output = "";
      for (i = 0; i < text.length; i++){
         size = parseInt(getTextSize(i +dis,method,text.length));
         output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
      }
      var container = document.getElementById('container');
      container.innerHTML = output;
    }
     
    function run(n){  
      var content = "======欢迎分享JavaScript======";
      changeTextSize(content,1,n);
      if (n > content.length) {n=0}
      setTimeout("run(" + (n+1) + ")", 50);
    }
    window.onload = run(0);
</script>
</html>
